<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org"
      xmlns:sec="http://www.thymeleaf.org/thymeleaf-extras-springsecurity5">
<head>
    <meta charset="utf-8">
    <title>权限管理系统</title>
    <link rel="stylesheet" th:href="@{css/bootstrap.min.css}">
    <link rel="stylesheet" th:href="@{css/main.css}">
</head>
<body>
<nav class="navbar navbar-dark sticky-top bg-dark flex-md-nowrap p-0 shadow">
    <a class="navbar-brand col-md-3 col-lg-2 mr-0 px-3" href="#">
        权限管理系统，您好：
        <span sec:authentication="principal.username"></span>
    </a>

    <ul class="navbar-nav px-3">
        <li class="nav-item text-nowrap">
            <form th:action="@{/logout}" method="post">
                <input class="btn btn-danger btn-sm" type="submit" value="退出">
            </form>
        </li>
    </ul>
</nav>

<div class="container-fluid">
    <div class="row">
        <nav class="col-md-3 col-lg-2 bg-light sidebar">
            <div class="sidebar-sticky pt-3">
                <ul class="nav flex-column">
                    <li class="nav-item border-bottom" sec:authorize="hasAnyRole('ROLE_ADMIN', 'ROLE_USER')">
                        <p><a href="#">用户管理</a></p>
                        <ul>
                            <li><a th:href="@{user/add}" target="container">添加用户</a></li>
                            <li><a th:href="@{user/findAll}" target="container">用户列表</a></li>
                        </ul>
                    </li>
                    <li class="nav-item border-bottom" sec:authorize="hasAnyRole('ROLE_ADMIN')">
                        <p><a href="#">角色管理</a></p>
                        <ul>
                            <li><a th:href="@{role/add}" target="container">添加角色</a></li>
                            <li><a th:href="@{role/findAll}" target="container">角色列表</a></li>
                        </ul>
                    </li>
                </ul>
            </div>
        </nav>

        <main class="col-md-9 ml-sm-auto col-lg-10 px-md-4">
            <iframe name="container" width="100%" height="800px" frameborder="0"/>
        </main>
    </div>
</div>
<script th:src="@{js/jquery-3.5.1.min.js}"></script>
<script th:src="@{js/bootstrap.bundle.min.js}"></script>
</body>
</html>